﻿#pragma once

#include "Action.h"
#include "CommandLine.h"
#include "EulerSystem.h"
#include "Executioner.h"
#include "ImgOutput.h"
#include "Logging.h"
#include "NavierStokesSystem.h"
#include "Parser.h"
#include "SystemBase.h"
#include "VTKOutput.h"

#include <algorithm>
#include <chrono>
#include <memory>

class Executioner;
class CreateMeshAction;
class Action;

class Application
{
public:
  Application(int argc, char** argv);
  ~Application();

  virtual void PrintLogo();

  // 解析命令行
  void ParseCLI();
 
  // 解析配置文件
  void ParseInputFile();
  
  void Run();

protected:
  void CreateSystem()
  {

    GetPot cf(_ifile);
    auto sections = cf.get_section_names();

    std::string pos = "Executioner/";
    cf.set_prefix(pos);
    auto dt = cf.get<FloatDefault>("dt");
    auto steps = cf.get<Id>("steps");
    _sys->Init(dt, steps);
  }
  void Parse() {}

public:
  std::shared_ptr<Parser>& GetParser() { return this->_parser; }
  std::shared_ptr<MeshBase>& GetMesh() { return this->_mesh; }
  std::shared_ptr<EulerSystem>& GetSystem() { return this->_sys; }

private:
  std::string _ifile;
  CommandLine _cl;
  std::shared_ptr<Parser> _parser;

  std::shared_ptr<MeshBase> _mesh;
  std::shared_ptr<EulerSystem> _sys;

  std::vector<std::shared_ptr<Action>> _awh; // action warehouse
};
